#!/bin/sh

set -e

host="$1"
shift
port="$1"
shift
cmd="$@"

until nc -z "$host" "$port"; do
  >&2 echo "等待 $host:$port 就绪..."
  sleep 1
done

>&2 echo "$host:$port 已就绪，开始执行命令"
exec $cmd